Data Viz Yelp R Project

This project analyzes a subset of the yelp data from the Yelp Academic Dataset Challenge which has been stored in an Oracle database.

This is how my RStudio is configured:

sessionInfo()
## R version 3.0.1 (2013-05-16)
## Platform: x86_64-apple-darwin10.8.0 (64-bit)
## 
## locale:
## [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
## 
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base     
## 
## loaded via a namespace (and not attached):
## [1] digest_0.6.4     evaluate_0.5.5   formatR_1.0      htmltools_0.2.4 
## [5] knitr_1.6        rmarkdown_0.2.64 stringr_0.6.2    tools_3.0.1     
## [9] yaml_2.1.13

These are the packages I load from .Rprofile:

# To get this to work in your environment, change the following directory/folder path to the path to your project files.
setwd("~/Dropbox/Classes/DataViz/DataVizYelp/RProject/")
system("cat .Rprofile", intern = TRUE)
## Warning: running command 'cat .Rprofile' had status 1
## character(0)
## attr(,"status")
## [1] 1

Yelp Data Model

Yelp Data

yelp.ddl

# To get this to work in your environment, change the following directory/folder path to the path to your project files.
setwd("~/Dropbox/Classes/DataViz/DataVizYelp/RProject/02YelpData/")
system("cat yelp.ddl", intern = TRUE)
##   [1] "-- Generated by Oracle SQL Developer Data Modeler 4.0.0.833"                                                                            
##   [2] "--   at:        2014-09-11 00:39:21 CDT"                                                                                                
##   [3] "--   site:      Oracle Database 12c"                                                                                                    
##   [4] "--   type:      Oracle Database 12c"                                                                                                    
##   [5] ""                                                                                                                                       
##   [6] ""                                                                                                                                       
##   [7] ""                                                                                                                                       
##   [8] ""                                                                                                                                       
##   [9] "DROP TABLE Business_neighborhood CASCADE CONSTRAINTS ;"                                                                                 
##  [10] ""                                                                                                                                       
##  [11] "DROP TABLE Attribute_business CASCADE CONSTRAINTS ;"                                                                                    
##  [12] ""                                                                                                                                       
##  [13] "DROP TABLE Elite_year_yelper CASCADE CONSTRAINTS ;"                                                                                     
##  [14] ""                                                                                                                                       
##  [15] "DROP TABLE Business_category CASCADE CONSTRAINTS ;"                                                                                     
##  [16] ""                                                                                                                                       
##  [17] "DROP TABLE Yelper_friend CASCADE CONSTRAINTS ;"                                                                                         
##  [18] ""                                                                                                                                       
##  [19] "DROP TABLE attribute CASCADE CONSTRAINTS ;"                                                                                             
##  [20] ""                                                                                                                                       
##  [21] "DROP TABLE business CASCADE CONSTRAINTS ;"                                                                                              
##  [22] ""                                                                                                                                       
##  [23] "DROP TABLE category CASCADE CONSTRAINTS ;"                                                                                              
##  [24] ""                                                                                                                                       
##  [25] "DROP TABLE checkin CASCADE CONSTRAINTS ;"                                                                                               
##  [26] ""                                                                                                                                       
##  [27] "DROP TABLE checkin_info CASCADE CONSTRAINTS ;"                                                                                          
##  [28] ""                                                                                                                                       
##  [29] "DROP TABLE compliment CASCADE CONSTRAINTS ;"                                                                                            
##  [30] ""                                                                                                                                       
##  [31] "DROP TABLE elite_year CASCADE CONSTRAINTS ;"                                                                                            
##  [32] ""                                                                                                                                       
##  [33] "DROP TABLE hours CASCADE CONSTRAINTS ;"                                                                                                 
##  [34] ""                                                                                                                                       
##  [35] "DROP TABLE neighborhood CASCADE CONSTRAINTS ;"                                                                                          
##  [36] ""                                                                                                                                       
##  [37] "DROP TABLE review CASCADE CONSTRAINTS ;"                                                                                                
##  [38] ""                                                                                                                                       
##  [39] "DROP TABLE yelper CASCADE CONSTRAINTS ;"                                                                                                
##  [40] ""                                                                                                                                       
##  [41] "DROP TABLE vote CASCADE CONSTRAINTS ;"                                                                                                  
##  [42] ""                                                                                                                                       
##  [43] "CREATE TABLE Business_neighborhood"                                                                                                     
##  [44] "  ("                                                                                                                                    
##  [45] "    business_id     NUMBER NOT NULL ,"                                                                                                  
##  [46] "    neighborhood_id NUMBER NOT NULL"                                                                                                    
##  [47] "  ) ;"                                                                                                                                  
##  [48] "ALTER TABLE Business_neighborhood ADD CONSTRAINT Business_neighborhood__IDX PRIMARY KEY ( business_id, neighborhood_id ) ;"             
##  [49] ""                                                                                                                                       
##  [50] "CREATE TABLE Attribute_business"                                                                                                        
##  [51] "  ("                                                                                                                                    
##  [52] "    attribute_id NUMBER NOT NULL ,"                                                                                                     
##  [53] "    business_id  NUMBER NOT NULL"                                                                                                       
##  [54] "  ) ;"                                                                                                                                  
##  [55] "ALTER TABLE Attribute_business ADD CONSTRAINT Attribute_business__IDX PRIMARY KEY ( attribute_id, business_id ) ;"                      
##  [56] ""                                                                                                                                       
##  [57] "CREATE TABLE Elite_year_yelper"                                                                                                         
##  [58] "  ("                                                                                                                                    
##  [59] "    elite_year_id NUMBER NOT NULL ,"                                                                                                    
##  [60] "    yelper_id     NUMBER NOT NULL"                                                                                                      
##  [61] "  ) ;"                                                                                                                                  
##  [62] "ALTER TABLE Elite_year_yelper ADD CONSTRAINT Elite_year_yelper__IDX PRIMARY KEY ( elite_year_id, yelper_id ) ;"                         
##  [63] ""                                                                                                                                       
##  [64] "CREATE TABLE Business_category"                                                                                                         
##  [65] "  ("                                                                                                                                    
##  [66] "    business_id NUMBER NOT NULL ,"                                                                                                      
##  [67] "    category_id NUMBER NOT NULL"                                                                                                        
##  [68] "  ) ;"                                                                                                                                  
##  [69] "ALTER TABLE Business_category ADD CONSTRAINT Business_category__IDX PRIMARY KEY ( business_id, category_id ) ;"                         
##  [70] ""                                                                                                                                       
##  [71] "CREATE TABLE Yelper_friend"                                                                                                             
##  [72] "  ("                                                                                                                                    
##  [73] "    yelper_id  NUMBER NOT NULL ,"                                                                                                       
##  [74] "    friend_id  NUMBER NOT NULL"                                                                                                         
##  [75] "  ) ;"                                                                                                                                  
##  [76] "ALTER TABLE Yelper_friend ADD CONSTRAINT Yelper_friend__IDX PRIMARY KEY ( yelper_id, friend_id ) ;"                                     
##  [77] ""                                                                                                                                       
##  [78] "CREATE TABLE attribute"                                                                                                                 
##  [79] "  ("                                                                                                                                    
##  [80] "    attribute_id    NUMBER NOT NULL ,"                                                                                                  
##  [81] "    attribute_name  VARCHAR2 (4000) ,"                                                                                                  
##  [82] "    attribute_value VARCHAR2 (4000)"                                                                                                    
##  [83] "  ) ;"                                                                                                                                  
##  [84] "ALTER TABLE attribute ADD CONSTRAINT attribute_PK PRIMARY KEY ( attribute_id ) ;"                                                       
##  [85] ""                                                                                                                                       
##  [86] "CREATE TABLE business"                                                                                                                  
##  [87] "  ("                                                                                                                                    
##  [88] "    business_id     NUMBER NOT NULL ,"                                                                                                  
##  [89] "    business_id_str VARCHAR2 (30) ,"                                                                                                    
##  [90] "    business_name   VARCHAR2 (4000) ,"                                                                                                  
##  [91] "    address         VARCHAR2 (4000) ,"                                                                                                  
##  [92] "    city            VARCHAR2 (4000) ,"                                                                                                  
##  [93] "    state           VARCHAR2 (4000) ,"                                                                                                  
##  [94] "    latitude        NUMBER (18,15) ,"                                                                                                   
##  [95] "    longitude       NUMBER (18,15) ,"                                                                                                   
##  [96] "    stars           NUMBER (2,1) ,"                                                                                                     
##  [97] "    review_count    NUMBER ,"                                                                                                           
##  [98] "    business_open   VARCHAR2 (4000)"                                                                                                    
##  [99] "  ) ;"                                                                                                                                  
## [100] "ALTER TABLE business ADD CONSTRAINT business_PK PRIMARY KEY ( business_id ) ;"                                                          
## [101] ""                                                                                                                                       
## [102] "CREATE TABLE category"                                                                                                                  
## [103] "  ("                                                                                                                                    
## [104] "    category_id   NUMBER NOT NULL ,"                                                                                                    
## [105] "    category_name VARCHAR2 (4000)"                                                                                                      
## [106] "  ) ;"                                                                                                                                  
## [107] "ALTER TABLE category ADD CONSTRAINT category_PK PRIMARY KEY ( category_id ) ;"                                                          
## [108] ""                                                                                                                                       
## [109] "CREATE TABLE checkin"                                                                                                                   
## [110] "  ("                                                                                                                                    
## [111] "    checkin_id  NUMBER NOT NULL ,"                                                                                                      
## [112] "    business_id NUMBER"                                                                                                                 
## [113] "  ) ;"                                                                                                                                  
## [114] "ALTER TABLE checkin ADD CONSTRAINT checkin_PK PRIMARY KEY ( checkin_id ) ;"                                                             
## [115] ""                                                                                                                                       
## [116] "CREATE TABLE checkin_info"                                                                                                              
## [117] "  ("                                                                                                                                    
## [118] "    checkin_info_id NUMBER NOT NULL ,"                                                                                                  
## [119] "    checkin_time    VARCHAR2 (4000) ,"                                                                                                  
## [120] "    checkin_count   NUMBER ,"                                                                                                           
## [121] "    checkin_id      NUMBER NOT NULL"                                                                                                    
## [122] "  ) ;"                                                                                                                                  
## [123] "ALTER TABLE checkin_info ADD CONSTRAINT checkin_info_PK PRIMARY KEY ( checkin_info_id ) ;"                                              
## [124] ""                                                                                                                                       
## [125] "CREATE TABLE compliment"                                                                                                                
## [126] "  ("                                                                                                                                    
## [127] "    compliment_id    NUMBER NOT NULL ,"                                                                                                 
## [128] "    compliment_type  VARCHAR2 (4000) ,"                                                                                                 
## [129] "    compliment_count NUMBER ,"                                                                                                          
## [130] "    yelper_id        NUMBER"                                                                                                            
## [131] "  ) ;"                                                                                                                                  
## [132] "ALTER TABLE compliment ADD CONSTRAINT compliment_PK PRIMARY KEY ( compliment_id ) ;"                                                    
## [133] ""                                                                                                                                       
## [134] "CREATE TABLE elite_year"                                                                                                                
## [135] "  ("                                                                                                                                    
## [136] "    elite_year_id NUMBER NOT NULL ,"                                                                                                    
## [137] "    elite_year    VARCHAR2 (4000)"                                                                                                      
## [138] "  ) ;"                                                                                                                                  
## [139] "ALTER TABLE elite_year ADD CONSTRAINT elite_year_PK PRIMARY KEY ( elite_year_id ) ;"                                                    
## [140] ""                                                                                                                                       
## [141] "CREATE TABLE hours"                                                                                                                     
## [142] "  ("                                                                                                                                    
## [143] "    hours_id    NUMBER NOT NULL ,"                                                                                                      
## [144] "    hours_day   VARCHAR2 (4000) ,"                                                                                                      
## [145] "    hours_open  VARCHAR2 (4000) ,"                                                                                                      
## [146] "    hours_time  VARCHAR2 (4000) ,"                                                                                                      
## [147] "    business_id NUMBER"                                                                                                                 
## [148] "  ) ;"                                                                                                                                  
## [149] "ALTER TABLE hours ADD CONSTRAINT hours_PK PRIMARY KEY ( hours_id ) ;"                                                                   
## [150] ""                                                                                                                                       
## [151] "CREATE TABLE neighborhood"                                                                                                              
## [152] "  ("                                                                                                                                    
## [153] "    neighborhood_id   NUMBER NOT NULL ,"                                                                                                
## [154] "    neighborhood_name VARCHAR2 (4000)"                                                                                                  
## [155] "  ) ;"                                                                                                                                  
## [156] "ALTER TABLE neighborhood ADD CONSTRAINT neighborhood_PK PRIMARY KEY ( neighborhood_id ) ;"                                              
## [157] ""                                                                                                                                       
## [158] "CREATE TABLE review"                                                                                                                    
## [159] "  ("                                                                                                                                    
## [160] "    review_id   NUMBER NOT NULL ,"                                                                                                      
## [161] "    yelper_id   NUMBER ,"                                                                                                               
## [162] "    stars       NUMBER (2,1) ,"                                                                                                         
## [163] "    text        VARCHAR2 (4000) ,"                                                                                                      
## [164] "    review_date DATE ,"                                                                                                                 
## [165] "    business_id NUMBER"                                                                                                                 
## [166] "  ) ;"                                                                                                                                  
## [167] "ALTER TABLE review ADD CONSTRAINT review_PK PRIMARY KEY ( review_id ) ;"                                                                
## [168] ""                                                                                                                                       
## [169] "CREATE TABLE yelper"                                                                                                                    
## [170] "  ("                                                                                                                                    
## [171] "    yelper_id       NUMBER NOT NULL ,"                                                                                                  
## [172] "    yelper_id_str   VARCHAR2 (30) ,"                                                                                                    
## [173] "    yelper_name     VARCHAR2 (4000) ,"                                                                                                  
## [174] "    review_count    NUMBER ,"                                                                                                           
## [175] "    average_stars   NUMBER (18,17) ,"                                                                                                   
## [176] "    yelping_since   DATE ,"                                                                                                             
## [177] "    fans            NUMBER"                                                                                                             
## [178] "  ) ;"                                                                                                                                  
## [179] "ALTER TABLE yelper ADD CONSTRAINT yelper_PK PRIMARY KEY ( yelper_id ) ;"                                                                
## [180] ""                                                                                                                                       
## [181] "CREATE TABLE vote"                                                                                                                      
## [182] "  ("                                                                                                                                    
## [183] "    vote_id    NUMBER NOT NULL ,"                                                                                                       
## [184] "    vote_type  VARCHAR2 (4000) ,"                                                                                                       
## [185] "    vote_count NUMBER ,"                                                                                                                
## [186] "    yelper_id  NUMBER,"                                                                                                                 
## [187] "    review_id  NUMBER"                                                                                                                  
## [188] "  ) ;"                                                                                                                                  
## [189] "ALTER TABLE vote ADD CONSTRAINT vote_PK PRIMARY KEY ( vote_id ) ;"                                                                      
## [190] ""                                                                                                                                       
## [191] "ALTER TABLE Business_neighborhood ADD CONSTRAINT FK_ASS_1 FOREIGN KEY ( business_id ) REFERENCES business ( business_id ) ;"            
## [192] ""                                                                                                                                       
## [193] "ALTER TABLE Elite_year_yelper ADD CONSTRAINT FK_ASS_10 FOREIGN KEY ( yelper_id ) REFERENCES yelper ( yelper_id ) ;"                     
## [194] ""                                                                                                                                       
## [195] "ALTER TABLE Business_category ADD CONSTRAINT FK_ASS_12 FOREIGN KEY ( business_id ) REFERENCES business ( business_id ) ;"               
## [196] ""                                                                                                                                       
## [197] "ALTER TABLE Business_category ADD CONSTRAINT FK_ASS_13 FOREIGN KEY ( category_id ) REFERENCES category ( category_id ) ;"               
## [198] ""                                                                                                                                       
## [199] "ALTER TABLE Yelper_friend ADD CONSTRAINT FK_ASS_19 FOREIGN KEY ( yelper_id ) REFERENCES yelper ( yelper_id ) ;"                         
## [200] ""                                                                                                                                       
## [201] "ALTER TABLE Business_neighborhood ADD CONSTRAINT FK_ASS_2 FOREIGN KEY ( neighborhood_id ) REFERENCES neighborhood ( neighborhood_id ) ;"
## [202] ""                                                                                                                                       
## [203] "ALTER TABLE Yelper_friend ADD CONSTRAINT FK_ASS_20 FOREIGN KEY ( friend_id ) REFERENCES yelper ( yelper_id ) ;"                         
## [204] ""                                                                                                                                       
## [205] "ALTER TABLE Attribute_business ADD CONSTRAINT FK_ASS_3 FOREIGN KEY ( attribute_id ) REFERENCES attribute ( attribute_id ) ;"            
## [206] ""                                                                                                                                       
## [207] "ALTER TABLE Attribute_business ADD CONSTRAINT FK_ASS_4 FOREIGN KEY ( business_id ) REFERENCES business ( business_id ) ;"               
## [208] ""                                                                                                                                       
## [209] "ALTER TABLE Elite_year_yelper ADD CONSTRAINT FK_ASS_9 FOREIGN KEY ( elite_year_id ) REFERENCES elite_year ( elite_year_id ) ;"          
## [210] ""                                                                                                                                       
## [211] "ALTER TABLE checkin ADD CONSTRAINT checkin_business_FK FOREIGN KEY ( business_id ) REFERENCES business ( business_id ) ;"               
## [212] ""                                                                                                                                       
## [213] "ALTER TABLE checkin_info ADD CONSTRAINT checkin_info_checkin_FK FOREIGN KEY ( checkin_id ) REFERENCES checkin ( checkin_id ) ;"         
## [214] ""                                                                                                                                       
## [215] "ALTER TABLE compliment ADD CONSTRAINT compliment_yelper_FK FOREIGN KEY ( yelper_id ) REFERENCES yelper ( yelper_id ) ;"                 
## [216] ""                                                                                                                                       
## [217] "ALTER TABLE hours ADD CONSTRAINT hours_business_FK FOREIGN KEY ( business_id ) REFERENCES business ( business_id ) ;"                   
## [218] ""                                                                                                                                       
## [219] "ALTER TABLE review ADD CONSTRAINT review_business_FK FOREIGN KEY ( business_id ) REFERENCES business ( business_id ) ;"                 
## [220] ""                                                                                                                                       
## [221] "ALTER TABLE review ADD CONSTRAINT review_yelper_FK FOREIGN KEY ( yelper_id ) REFERENCES yelper ( yelper_id ) ;"                         
## [222] ""                                                                                                                                       
## [223] "ALTER TABLE vote ADD CONSTRAINT vote_yelper_FK FOREIGN KEY ( yelper_id ) REFERENCES yelper ( yelper_id ) ;"                             
## [224] ""                                                                                                                                       
## [225] "ALTER TABLE vote ADD CONSTRAINT vote_review_FK FOREIGN KEY ( review_id ) REFERENCES review ( review_id ) ;"                             
## [226] ""                                                                                                                                       
## [227] ""                                                                                                                                       
## [228] "-- Oracle SQL Developer Data Modeler Summary Report: "                                                                                  
## [229] "-- "                                                                                                                                    
## [230] "-- CREATE TABLE                            18"                                                                                          
## [231] "-- CREATE INDEX                             0"                                                                                          
## [232] "-- ALTER TABLE                             40"                                                                                          
## [233] "-- CREATE VIEW                              0"                                                                                          
## [234] "-- CREATE PACKAGE                           0"                                                                                          
## [235] "-- CREATE PACKAGE BODY                      0"                                                                                          
## [236] "-- CREATE PROCEDURE                         0"                                                                                          
## [237] "-- CREATE FUNCTION                          0"                                                                                          
## [238] "-- CREATE TRIGGER                           0"                                                                                          
## [239] "-- ALTER TRIGGER                            0"                                                                                          
## [240] "-- CREATE COLLECTION TYPE                   0"                                                                                          
## [241] "-- CREATE STRUCTURED TYPE                   0"                                                                                          
## [242] "-- CREATE STRUCTURED TYPE BODY              0"                                                                                          
## [243] "-- CREATE CLUSTER                           0"                                                                                          
## [244] "-- CREATE CONTEXT                           0"                                                                                          
## [245] "-- CREATE DATABASE                          0"                                                                                          
## [246] "-- CREATE DIMENSION                         0"                                                                                          
## [247] "-- CREATE DIRECTORY                         0"                                                                                          
## [248] "-- CREATE DISK GROUP                        0"                                                                                          
## [249] "-- CREATE ROLE                              0"                                                                                          
## [250] "-- CREATE ROLLBACK SEGMENT                  0"                                                                                          
## [251] "-- CREATE SEQUENCE                          0"                                                                                          
## [252] "-- CREATE MATERIALIZED VIEW                 0"                                                                                          
## [253] "-- CREATE SYNONYM                           0"                                                                                          
## [254] "-- CREATE TABLESPACE                        0"                                                                                          
## [255] "-- CREATE USER                              0"                                                                                          
## [256] "-- "                                                                                                                                    
## [257] "-- DROP TABLESPACE                          0"                                                                                          
## [258] "-- DROP DATABASE                            0"                                                                                          
## [259] "-- "                                                                                                                                    
## [260] "-- REDACTION POLICY                         0"                                                                                          
## [261] "-- TSDP POLICY                              0"                                                                                          
## [262] "-- "                                                                                                                                    
## [263] "-- ERRORS                                   0"                                                                                          
## [264] "-- WARNINGS                                 0"

First few rows of business.dml

# To get this to work in your environment, change the following directory/folder path to the path to your project files.
setwd("~/Dropbox/Classes/DataViz/DataVizYelp/RProject/02YelpData/")
system("head business.dml.head", intern = TRUE)
##  [1] "INSERT INTO business (business_id, business_id_str, business_name, address, city, state, latitude, longitude, stars, review_count, business_open) VALUES (39630, q'#OlpyplEJ_c_hFxyand_Wxw#', q'#Inchin Bamboo Garden#', q'#10050 N Scottsdale Rd"   
##  [2] "Ste 121"                                                                                                                                                                                                                                             
##  [3] "Paradise Valley, AZ 85253#', q'#Paradise Valley#', q'#AZ#', 33.575816, -111.926234, 3.5, 44, q'#1#');"                                                                                                                                               
##  [4] "INSERT INTO business (business_id, business_id_str, business_name, address, city, state, latitude, longitude, stars, review_count, business_open) VALUES (33751, q'#MJtnKhA3l-2ZFzhneuSccw#', q'#The Steakhouse at The Pass#', q'#2800 S Boulder Hwy"
##  [5] "Henderson, NV 89002#', q'#Henderson#', q'#NV#', 35.9720758434016, -114.91103930658, 4.0, 9, q'#1#');"                                                                                                                                                
##  [6] "INSERT INTO business (business_id, business_id_str, business_name, address, city, state, latitude, longitude, stars, review_count, business_open) VALUES (11191, q'#s5yzZITWU_RcJzWOgjFecw#', q'#Sergio's Italian Gardens#', q'#1955 E Tropicana Ave"
##  [7] "Eastside"                                                                                                                                                                                                                                            
##  [8] "Las Vegas, NV 89119#', q'#Las Vegas#', q'#NV#', 36.100414, -115.1265829, 4.0, 67, q'#1#');"                                                                                                                                                          
##  [9] "INSERT INTO business (business_id, business_id_str, business_name, address, city, state, latitude, longitude, stars, review_count, business_open) VALUES (598, q'#VZYMInkjRJVHwXVFqeoMWg#', q'#Jack-In-the-Box#', q'#3215 N Central Ave"             
## [10] "Phoenix, AZ 85012#', q'#Phoenix#', q'#AZ#', 33.486194, -112.073895, 3.5, 4, q'#1#');"

First few rows of user.dml

# To get this to work in your environment, change the following directory/folder path to the path to your project files.
setwd("~/Dropbox/Classes/DataViz/DataVizYelp/RProject/02YelpData/")
system("head user.dml.head", intern = TRUE)
##  [1] "INSERT INTO yelper (yelper_id, yelper_id_str, yelper_name, review_count, average_stars, yelping_since, fans) VALUES (27883, q'#TmASe-BvImVAEe6hSC6oSw#', q'#Greg#', 6, 4.33, to_date('2013-04', 'YYYY-MM'), 1);"       
##  [2] "INSERT INTO yelper (yelper_id, yelper_id_str, yelper_name, review_count, average_stars, yelping_since, fans) VALUES (171442, q'#xeG6FneBvVEebZZQ3mxIxw#', q'#Danielle#', 2, 5.0, to_date('2013-02', 'YYYY-MM'), 0);"   
##  [3] "INSERT INTO yelper (yelper_id, yelper_id_str, yelper_name, review_count, average_stars, yelping_since, fans) VALUES (112194, q'#nB8jGRnXcRLt-s9UdT_PhQ#', q'#Shannon#', 1, 5.0, to_date('2012-04', 'YYYY-MM'), 1);"    
##  [4] "INSERT INTO yelper (yelper_id, yelper_id_str, yelper_name, review_count, average_stars, yelping_since, fans) VALUES (69195, q'#mTDwQ4I2hAHz2i5AC1ab3w#', q'#Christie#', 314, 3.69, to_date('2005-11', 'YYYY-MM'), 30);"
##  [5] "INSERT INTO yelper (yelper_id, yelper_id_str, yelper_name, review_count, average_stars, yelping_since, fans) VALUES (124774, q'#5QA888BgPj1Ln3Vqla99hg#', q'#Pedro#', 2, 3.0, to_date('2012-04', 'YYYY-MM'), 0);"      
##  [6] "INSERT INTO yelper (yelper_id, yelper_id_str, yelper_name, review_count, average_stars, yelping_since, fans) VALUES (115472, q'#-o6LK0LdVlQcE2h7pdoFuA#', q'#Matt#', 1, 5.0, to_date('2013-05', 'YYYY-MM'), 0);"       
##  [7] "INSERT INTO yelper (yelper_id, yelper_id_str, yelper_name, review_count, average_stars, yelping_since, fans) VALUES (248566, q'#XN32hHpbNYkny8SwJ5WOVQ#', q'#Lou C.#', 421, 3.67, to_date('2011-06', 'YYYY-MM'), 14);" 
##  [8] "INSERT INTO yelper (yelper_id, yelper_id_str, yelper_name, review_count, average_stars, yelping_since, fans) VALUES (138309, q'#CepCmY5DDYoskMh0cmxLfA#', q'#Julie#', 3, 2.67, to_date('2013-02', 'YYYY-MM'), 0);"     
##  [9] "INSERT INTO yelper (yelper_id, yelper_id_str, yelper_name, review_count, average_stars, yelping_since, fans) VALUES (134738, q'#UwnXA4ox3K9RMGaRwqgaBw#', q'#Nicole#', 14, 3.57, to_date('2010-12', 'YYYY-MM'), 0);"   
## [10] "INSERT INTO yelper (yelper_id, yelper_id_str, yelper_name, review_count, average_stars, yelping_since, fans) VALUES (180503, q'#sxULQivO3NiCIDmWfZDSnA#', q'#Shari#', 3, 2.33, to_date('2012-12', 'YYYY-MM'), 1);"

Python script to convert Yelp json to our sql.

# To get this to work in your environment, change the following
# directory/folder path to the path to your project files.
setwd("~/Dropbox/Classes/DataViz/DataVizYelp/python")
system("ls convert.py", intern = TRUE)
## [1] "convert.py"
source("../03Analysis/YelpAnalysis.R", echo = TRUE)
## 
## > library("ggplot2", lib.loc = "/Library/Frameworks/R.framework/Versions/3.0/Resources/library")
## Warning: package 'ggplot2' was built under R version 3.0.2
## 
## > library("lubridate", lib.loc = "/Library/Frameworks/R.framework/Versions/3.0/Resources/library")
## Warning: package 'lubridate' was built under R version 3.0.2
## 
## > options(java.parameters = "-Xmx2g")
## 
## > library(rJava)
## Warning: package 'rJava' was built under R version 3.0.2
## 
## > library(RJDBC)
## Warning: package 'RJDBC' was built under R version 3.0.2
## Loading required package: DBI
## Warning: package 'DBI' was built under R version 3.0.2
## 
## > library(ggmap)
## Warning: package 'ggmap' was built under R version 3.0.2
## 
## > jdbcDriver <- JDBC(driverClass = "oracle.jdbc.OracleDriver", 
## +     classPath = "/Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home/ojd ..." ... [TRUNCATED] 
## 
## > possibleError <- tryCatch(jdbcConnection <- dbConnect(jdbcDriver, 
## +     "jdbc:oracle:thin:@128.83.138.158:1521:orcl", "C##cs347_jab5948", 
## +     "o ..." ... [TRUNCATED] 
## 
## > if (!inherits(possibleError, "error")) {
## +     users <- dbGetQuery(jdbcConnection, "select review_count, average_stars from yelper")
## +     businesse .... [TRUNCATED] 
## [1] TRUE
## 
## > head(users)
##   REVIEW_COUNT AVERAGE_STARS
## 1            6          4.33
## 2            2          5.00
## 3            1          5.00
## 4          314          3.69
## 5            2          3.00
## 6            1          5.00
## 
## > ggplot(data = users, aes(x = REVIEW_COUNT, y = ..count..)) + 
## +     geom_histogram(binwidth = 2, colour = "#56B4E9", fill = "#56B4E9") + 
## +     geom .... [TRUNCATED]

plot of chunk unnamed-chunk-7

## 
## > ggplot(data = users, aes(x = REVIEW_COUNT, y = ..count..)) + 
## +     geom_histogram(binwidth = 2, colour = "#56B4E9", fill = "#56B4E9") + 
## +     geom .... [TRUNCATED]

plot of chunk unnamed-chunk-7

## 
## > ggplot(data = users, aes(x = REVIEW_COUNT)) + geom_histogram(aes(y = ..count..), 
## +     binwidth = 5, colour = "#56B4E9", fill = "#56B4E9") + geom_d .... [TRUNCATED]

plot of chunk unnamed-chunk-7

## 
## > ggplot(subset(users, AVERAGE_STARS != 0), aes(x = REVIEW_COUNT, 
## +     y = AVERAGE_STARS)) + geom_point(colour = "#56B4E9") + geom_hline(aes(yinterc .... [TRUNCATED]
## 
## > phoenix_map <- ggmap(get_googlemap("Phoenix, AZ"))
## Map from URL : http://maps.googleapis.com/maps/api/staticmap?center=Phoenix,+AZ&zoom=10&size=%20640x640&maptype=terrain&sensor=false
## Google Maps API Terms of Service : http://developers.google.com/maps/terms
## Information from URL : http://maps.googleapis.com/maps/api/geocode/json?address=Phoenix,+AZ&sensor=false
## Google Maps API Terms of Service : http://developers.google.com/maps/terms
## 
## > las_vegas_map <- ggmap(get_googlemap("Las Vegas, NV"))
## Map from URL : http://maps.googleapis.com/maps/api/staticmap?center=Las+Vegas,+NV&zoom=10&size=%20640x640&maptype=terrain&sensor=false
## Google Maps API Terms of Service : http://developers.google.com/maps/terms
## Information from URL : http://maps.googleapis.com/maps/api/geocode/json?address=Las+Vegas,+NV&sensor=false
## Google Maps API Terms of Service : http://developers.google.com/maps/terms
## 
## > edinburgh_map <- ggmap(get_googlemap("Edinburgh, UK"))
## Map from URL : http://maps.googleapis.com/maps/api/staticmap?center=Edinburgh,+UK&zoom=10&size=%20640x640&maptype=terrain&sensor=false
## Google Maps API Terms of Service : http://developers.google.com/maps/terms
## Information from URL : http://maps.googleapis.com/maps/api/geocode/json?address=Edinburgh,+UK&sensor=false
## Google Maps API Terms of Service : http://developers.google.com/maps/terms
## 
## > madison_map = ggmap(get_googlemap("Madison, WI"))
## Map from URL : http://maps.googleapis.com/maps/api/staticmap?center=Madison,+WI&zoom=10&size=%20640x640&maptype=terrain&sensor=false
## Google Maps API Terms of Service : http://developers.google.com/maps/terms
## Information from URL : http://maps.googleapis.com/maps/api/geocode/json?address=Madison,+WI&sensor=false
## Google Maps API Terms of Service : http://developers.google.com/maps/terms

plot of chunk unnamed-chunk-7

## 
## > b = c(1, 2, 3, 4, 5)
## 
## > phoenix_map + geom_point(data = phoenix, aes(x = LONGITUDE, 
## +     y = LATITUDE, color = STARS)) + ggtitle("Phoenix") + scale_colour_gradientn(limit .... [TRUNCATED]
## Warning: Removed 44 rows containing missing values (geom_point).

plot of chunk unnamed-chunk-7

## 
## > madison_map + geom_point(data = madison, aes(x = LONGITUDE, 
## +     y = LATITUDE, color = STARS)) + ggtitle("Madison") + scale_colour_gradientn(limit .... [TRUNCATED]

plot of chunk unnamed-chunk-7

## 
## > edinburgh_map + geom_point(data = edinburgh, aes(x = LONGITUDE, 
## +     y = LATITUDE, color = STARS)) + ggtitle("Edinburgh") + scale_colour_gradientn .... [TRUNCATED]

plot of chunk unnamed-chunk-7

## 
## > las_vegas_map + geom_point(data = las_vegas, aes(x = LONGITUDE, 
## +     y = LATITUDE, color = STARS)) + ggtitle("Las Vegas") + scale_colour_gradientn .... [TRUNCATED]

plot of chunk unnamed-chunk-7

## 
## > ggplot(businesses, aes(x = BUSINESS_REVIEW_COUNT, 
## +     y = STARS)) + geom_point(colour = "#56B4E9") + facet_wrap(~CITY)

plot of chunk unnamed-chunk-7

#library(shinyapps)
getwd()
## [1] "/Users/jacobbrouwer/Dropbox/Classes/DataViz/DataVizYelp/RProject/00Doc"
# Uncomment the following line to deploy the app.
# deployApp("../04Shiny")